<style lang="less">
@import "../../../static/css/JE.core.min.css";

.header-bar {
  position:absolute;
  width:100%;
  top:0;
  left:0;
  z-index:9999;
   .header-bg{
    box-sizing: unset;
    top:0;
    width:100%;
  }
   .header-bar-custom {
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    height: 90px;
    padding: 0 30px 0 30px;
    .left-option {
      text-align: left;
      i {
        font-size: 36px;
        color: #ffffff;
      }
      span {
        font-size: 32px;
        color: #ffffff;
        margin-left: 5px;
      }
    }
    .center-option {
      color: #ffffff;
      font-size: 36px;
      flex-grow: 1;
      flex: 1;
    }
    .right-option {
      text-align: right;
      i {
        font-size: 36px;
        color: #ffffff;
      }
      span {
        font-size: 32px;
        color: #ffffff;
        margin-left: 24px;
      }
    }
  }
}
</style>

<template>
  <div class="header-bar">
    <!-- 上边距离 -->
    <!-- <div
      :style="{height:handleImmer,background:bgColor}"
      class="header-bg"/> -->

    <!-- 头部 -->
    <div
      :style="headerStyle"
      class="header-bar-custom"
    >
      <template v-if="!isCustom">
        <!-- 左边内容 -->
        <div class="left-option option-item">
          <div
            v-if="showLeftBack"
            @tap="back"
          >
            <i
              :style="{color:leftColor}"
              class="jeicon jeicon-angle-left"
            />
            <span :style="{color:leftColor}">返回</span>
          </div>
          <div v-else>
            <slot name="leftOption" />
          </div>
        </div>
        <!-- 中间内容 -->
        <div
          :style="{color:centerColor}"
          class="center-option option-item"
        >
          <slot name="title" />
        </div>
        <!-- 右边距离 -->
        <div
          :style="{color:rightColor}"
          class="right-option option-item"
        >
          <slot name="rightOption" />
        </div>
      </template>
      <template v-else>
        <slot name="customHeader" />
      </template>
    </div>
  </div>
</template>

<script>
// import { handleImmer } from '@/helper/plugin';

export default {
  name: 'Headerbar',
  props: {
    centerColor: {
      // 中间操作区颜色
      type: String,
      default: '#ffffff',
    },
    leftColor: {
      // 返回字体的颜色
      type: String,
      default: '#ffffff',
    },
    rightColor: {
      // 右边颜色
      type: String,
      default: '#ffffff',
    },
    appointUrl: {
      // 主页链接 replace
      type: String,
      default: '',
    },
    bgColor: {
      // 背景颜色
      type: String,
      default: '#536DFE',
    },
    isCustom: {
      // 是否自定义
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      showLeftBack: false, // 是否显示返回
      headerStyle: {
        background: this.bgColor,
        // top: this.handleImmer || 0,
      },
    };
  },
  computed: {
    // handleImmer() {
    //   return handleImmer();
    // },
  },
  created() {},
  mounted() {
    this.headerStyle.top = this.handleImmer;
    if (this.$slots.leftOption) {
      this.showLeftBack = false;
    }
  },
  methods: {
    back() {
      if (this.appointUrl) {
        this.$router.replace({ name: this.appointUrl });
      } else {
        // this.$router.back(-1);
        mui.back();
      }
    },
  },
};
</script>
